<template>
  <div class="table-form">
    <!-- 表格 -->
    <hcTable
      ref="tableRef"
      :table-data="tableData"
      :options="options"
      :columns="tableColumn"
      @command="handleAction"
      @row-click="handleCurrentChange"
    >
    </hcTable>
  </div>
</template>

<script setup>
import { computed, ref } from "vue";

let props = defineProps({
  tableData: {
    type: Array,
    default: () => [],
  },
  tableColumn: {
    type: Array,
    default: () => [],
  },
  type: {
    type: String,
    default: "",
  },
});

let options = computed(() => {
  return {
    highlightCurrentRow: props.type == "pass" ? true : false,
    showPagination: false,
    border: true,
  };
});

let emit = defineEmits(["actionComman", "rowClick"]);

let tableRef = ref(null);

function handleAction(command, row) {
  emit("actionComman", { command, row });
}

function handleCurrentChange(row, column, event) {
  props.type == "pass" && emit("rowClick", { row, column, event });
}

defineExpose({
  tableRef,
});
</script>

<style lang="scss" scoped>
.table-form {
  padding: 0;
}
</style>
